package com.foreknow.mapping;

import com.foreknow.db.DBManager;

import java.util.HashMap;
import java.util.Map;

public class MappingFactory {
    private static MappingFactory mappingFactory = null;
    public Map<String,EntityMapping> maps = new HashMap<>();
    public static final String ADMIN_MAPPING = "adminMapping";
    public static final String GUESTBOOK_MAPPING = "guestbookMapping";

    private MappingFactory() {

    }

    public static MappingFactory getInstance() {
        if (mappingFactory == null) {
            mappingFactory = new MappingFactory();
            mappingFactory.maps.put(ADMIN_MAPPING,new AdminMapping());
            mappingFactory.maps.put(GUESTBOOK_MAPPING,new GuestbookMapping());
        }
        return mappingFactory;
    }

    /**
     * 从Map集合中获取xxxMapping对象
     */
    public EntityMapping getMapping(String key) {
        return maps.get(key);
    }
}
